<template>
  <el-container class="home-container">
    <!--头部-->
    <el-header>
      <div>
        <img src alt />

        <span>学生端</span>
      </div>
      <el-button type="info" @click="logout">退出</el-button>
    </el-header>
    <!--页面主体-->
    <el-container>
      <!--侧边栏-->
      <el-aside width="200px">
        <!--侧边栏菜单-->
        <el-menu background-color="#333744" text-color="#fff" router>
          <!--一级菜单-->
          <el-submenu index="1">
            <!--一级菜单模板区-->
            <template slot="title">
              <!--图标-->
              <i class="el-icon-reading"></i>
              <!--文本-->
              <span>课程管理</span>
            </template>
            <!--二级菜单-->
            <el-menu-item-group>
              <el-menu-item
                v-for="(item,i) in navList"
                :key="i"
                :index="item.name"
              >{{ item.navItem }}</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="2">
            <!--一级菜单模板区-->
            <template slot="title">
              <!--图标-->
              <i class="el-icon-document"></i>
              <!--文本-->
              <span>学习情况</span>
            </template>
            <!--二级菜单-->
            <el-menu-item-group>
              <el-menu-item
                v-for="(item,i) in stuList"
                :key="i"
                :index="item.name"
              >{{ item.navItem }}</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-menu-item index="stuworkview">
            <i class="el-icon-edit"></i>
            <span slot="title">查看作业</span>
          </el-menu-item>
          <el-menu-item index="stupersion">
            <i class="el-icon-menu"></i>
            <span slot="title">个人中心</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <!--右侧主体-->
      <el-main>
        <!--路由占位符-->
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  name: "Home",
  data() {
    return {
      navList: [
        { name: "/stucourse", navItem: "所有课程" },
        { name: "/coursemenu", navItem: "我的课程" },
      ],
      stuList: [
        { name: "/allbooks", navItem: "学习报表" },
        { name: "/stuGrade", navItem: "作业成绩" }
      ]
    };
  },
  methods: {
    logout() {
      window.sessionStorage.clear();
      this.$router.push("/");
    },
    work() {
      window.sessionStorage.clear();
      this.$router.push("/stuwork");
    },
    home() {
      window.sessionStorage.clear();
      this.$router.push("/stuhome");
    }
  }
};
</script>

<style scoped>
.home-container {
  height: 100%;
}

.el-header {
  background-color: #373d41;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #ffffff;
  font-size: 20px;
}

.el-aside {
  background-color: #333744;
}

.ell-main {
  background-color: #eaedf1;
}
</style>
